<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>修改个人中心</title>
    <link rel="stylesheet" href="/css/RegistrationFilling.css">
    <script src="/js/vue.js"></script>
    <script src="/js/axios.min.js"></script>
</head>
<body>
    <div id="app">
        <div class="mi-header">
            <div class="mi-title">
                <div class="mi-logo">
                    <img src="/img/Login/Login.jpg"  onclick="location.href=('Home.html')" width="60px" height="60px" />
                </div>
                小米账号
            </div>
            <div class="mi-nav">
                <a class="mi-nav__item url">用户协议</a>
                <a class="mi-nav__item url">隐私政策</a>
                <a class="mi-nav__item url">帮助中心</a>
            </div>
        </div>
        <div class="mi-body">
            <form action="">
                <p class="RegistrationUName">
                    呢称：<input type="text" id="UName" v-model="UserModel.userName" placeholder="昵称"  />
                </p>
                <p class="RegistrationUSex">
                    性别：<input type="radio" name="radioSex" v-model="UserModel.userGender" value="男" />男
                        <input type="radio" name="radioSex"  v-model="UserModel.userGender" value="女" />女
                </p>
                <p class="RegistrationUPwd">
                    密码：<input type="password" id="UPwd" v-model="UserModel.userPassWord" placeholder="密码"  />
                </p>
                <p class="RegistrationUAddress"  style="margin-left: 519px; margin-top: 4%;">
                      收货地址：<textarea id="UAddress" v-model="UserModel.userAddress" cols="30" rows="10"></textarea>
                </p>
                
                <input class="RegistrationSumbit" type="button" @click="sumbit()"  value="保存信息" />
            </form>
        </div>
    </div>
    <script src="/js/userscommon.js"></script>
    <script>
        let vm = new Vue({
           el:"#app",
           data:{
                UserModel:{
                    userID:0,
                    userAccount:'',
                    userPassWord:'',
                    userName:'',
                    userGender:'',
                    userPhone:'',
                    userAddress:'',
                    userPircture:'/img/MyPersonal/头像.jpg',
                    userDate:'',
                    userLocation:'中国',
                    userstate:'1',
                },
           },
           created: function () {
                // 获取跳转页面的url数据
                //首页传送的指定商品id从而获取对应商品信息
                var url = window.location.href
                var path = url.split('?')[1]
                var field = new URLSearchParams('?'+path)
                this.UserModel.userPhone = field.get('phone')
                this.getDate()
            },
           methods: {
                sumbit(){
                    axios.post('/user/update', vm.UserModel).then(function (resp) {
                        if (true == resp.data.result) {
                            alert("注册成功！")
                            location.href=('Login.html')
                        }else{
                            alert("注册失败")
                        }
                    })
                },
                getDate(){
                    var a  = parseInt(new Date().getTime() / 1000);
                    this.UserModel.userAccount = a.toString();
                }
           },
        })
   </script>
</body>
</html>